package com.njwb.day15.zqzb.ios.io2;

import java.io.*;

public class FileReaderDemo01 {
    public static void main(String[] args) {
        //专门用来处理字符数据的流
        Reader reader = null ;
        File f = new File("e:"+File.separator+"bak.txt");
        try {
            //处理单位就是字符
            reader = new FileReader(f);
            int count = 0 ;
            int value  = 0 ;
            while((value=reader.read())!=-1) {
                char c = (char) value;
                System.out.print(c);
                count++ ;
            }
            System.out.println("\n一共读取了"+count+"次");


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(reader!=null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
